package com.ljc.dao;

import com.ljc.entity.DevicePurchasePlanning;
import com.ljc.entity.DevicePurchasePlanningArgument;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface DevicePurchasePlanningArgumentDao {
        //project service invoke
    @Insert("insert into device_purchase_planning_argument(device_purchase_planning_id,expert_id) " +
            "values(#{devicePurchasePlanningId},#{expertId})")
    void  add(DevicePurchasePlanningArgument argument);

    @Select("select p.*,a.id argumentId,a.status argumentStatus from device_purchase_planning_argument a " +
            "left join device_purchase_planning p on a.device_purchase_planning_id=p.id " +
            "where a.device_purchase_planning_id in (select id from device_purchase_planning where project_planning_id=#{projectPlanningId}) " +
            "and a.expert_id=#{expertId}" )
    List<DevicePurchasePlanning> findByExpertAndProject(@Param("projectPlanningId")int projectPlanningId, @Param("expertId")int ExpertId);

    @Update("update device_purchase_planning_argument set score=#{score},opinion=#{opinion},operator=#{operator},date=#{date},status=2 " +
            "where id=#{id}")
    void argument(DevicePurchasePlanningArgument devicePurchasePlanningArgument);

   @Select("select * from device_purchase_planning_argument where id=#{id}")
    DevicePurchasePlanningArgument getById(int id);

   @Select("select * from  device_purchase_planning_argument \n" +
           "where device_purchase_planning_id=#{devicePurchasePlanningId} ")
   List<DevicePurchasePlanningArgument> getByDevicePlanningId(int devicePurchasePlanningId);
}
